/*访问app菜单api*/

import request from '@/utils/request'

const URL_PREFIX = '/iam/app-menu'

const fetch = function(id) {
  return request({
    url: `${URL_PREFIX}/${id}`,
    method: 'post'
  })
}

const fetchList = function(data) {
  return request({
    url: `${URL_PREFIX}/list`,
    method: 'post',
    data: data
  })
}

const save = function(data) {
  if (data.id === undefined) {
    return request({
      url: `${URL_PREFIX}/create`,
      method: 'post',
      data: data
    })
  } else {
    return request({
      url: `${URL_PREFIX}/edit`,
      method: 'post',
      data: data
    })
  }
}

const remove = function(id) {
  return request({
    url: `${URL_PREFIX}/del/${id}`,
    method: 'post'
  })
}

export default {
  fetch,
  save,
  remove,
  fetchList
}
